home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7963 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  61 lines

  1. Path: gail.ripco.com!mambuhl
  2. From: mambuhl@ripco.com (Martin Ambuhl)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Is this a compiler bu
  5. Date: 29 Feb 1996 22:23:57 GMT
  6. Organization: Ripco Communications, Inc.
  7. Message-ID: <4h591t$8nj@gail.ripco.com>
  8. NNTP-Posting-Host: golden.ripco.com
  9.  
  10. "Edward J. Huff" <huffe@carbon.chem.nyu.edu>
  11. in <3135FEDB.65AA@carbon.chem.nyu.edu> asks:
  12.  
  13. >Is this a bug?  Or is it "support for traditional practice"?
  14.  
  15. Neither, for my copy of gcc.  It is erroneous.
  16.  
  17. >==> static_bug.c <==
  18. >static const char foo[];
  19.  
  20. >int
  21. >main(int argc, const char *argv[]) {
  22. >  printf("foo = '%s'\n",foo);
  23. >  return 0;
  24. >}
  25.  
  26. >#ifdef DEFINE_IT
  27. >static const char foo[] = "bar";
  28. >#endif
  29.  
  30. >==> static_bug2.c <==
  31. >const char foo[] = "baz";
  32. >carbon% gcc static*.c
  33.  
  34. My copy of gcc reports (with my usual -Wall -ansi -pedantic):
  35. 1: array size missing in `foo'
  36.  In function `main':
  37. 5: warning: implicit declaration of function `printf'
  38.  
  39. >carbon% a.out
  40. >foo = 'baz'
  41.  
  42. ...and certainly does not produce an executable.
  43.  
  44. >carbon% gcc -DDEFINE_IT static*.c
  45.  
  46. My copy of gcc reports (with my usual -Wall -ansi -pedantic):
  47. 1: array size missing in `foo'
  48.  In function `main':
  49. 5: warning: implicit declaration of function `printf'
  50.  At top level:
  51. 10: warning: initializer-string for array of chars is too long
  52.  
  53. >carbon% a.out
  54. >foo = 'bar'
  55.  
  56. ...and certainly does not produce an executable.
  57.                                                                   
  58. --
  59. * Martin Ambuhl       net: mambuhl@ripco.com
  60. * Chicago, IL (USA)    
  61.